package com.tensquare.qa.config;

import com.tensquare.qa.interceptor.JwtInterceptor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurationSupport;

/**
 * @Description：拦截器配置类
 * @Author: liulei
 * @Date: 2019年10月31日
 * @Version: V1.0
 **/
@Configuration
public class InterceptorConfig extends WebMvcConfigurationSupport {

    @Autowired
    private JwtInterceptor jwtInterceptor;

    protected void addInterceptors(InterceptorRegistry registry) {
        //注册拦截器要声明拦截的对象和拦截的路径
        registry.addInterceptor(jwtInterceptor)
                .addPathPatterns("/**") //要拦截的路径
                .excludePathPatterns("/**/login/**");//排除不拦截的路径
    }
}
